package com.itheima.udp;

import java.net.*;

public class Client {

    public static void main(String[] args) throws Exception {
        //1.创建发送对象
        DatagramSocket ds = new DatagramSocket();
        //2.组织数据
        String s="你好";
        String ip="127.0.0.1";
        InetAddress ipAddress = InetAddress.getByName(ip);
        int port=8888;

        DatagramPacket dp = new DatagramPacket(s.getBytes(),s.getBytes().length,ipAddress,port);
        //3.调用发送方法
        ds.send(dp);
        //4.释放资源
        ds.close();

    }
}
